package com.zhongyouyun.admin.controller;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.tree.Tree;
import com.zhongyouyun.admin.model.DeptModel;
import com.zhongyouyun.admin.pojo.AnalysisPojo;
import com.zhongyouyun.admin.service.AnalysisService;
import com.zhongyouyun.other.annotation.DataAuthScope;
import com.zhongyouyun.other.annotation.SysLogAnnotation;
import com.zhongyouyun.other.model.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: shenyi
 * @Date: 2021-12-17
 * @Description:
 */
@RestController
@RequestMapping("/admin/z_analysis")
@Api(value = "统计分析controller", tags = {"统计分析接口"})
public class AnalysisController {
    @Autowired
    private AnalysisService service;

    @PostMapping("/findUserStateAnalysisbyDept")
    @ResponseBody
    @ApiOperation(value = "获取首页统计", notes = "获取首页统计列表")
    @SysLogAnnotation(operModul = "首页统计>>首页统计", operType = "首页统计", operDesc = "首页统计")
    @DataAuthScope(deptAlias = "temp_data_scope.")
    public Result findUserStateAnalysisbyDept(@NonNull @ApiParam(value = "deptId") @RequestParam(value = "deptId", required = false) Long deptId, @NonNull @ApiParam(value = "state") @RequestParam(value = "state", required = false) int state) {
        List<Map<String, Integer>> list = service.findUserStateAnalysisbyDept(deptId, state);
        if (list.size() > 0) {
            return Result.builder().message("成功").status(0).data(list).build();
        } else {
            return Result.builder().message("没有任何权限").status(1).success(false).build();
        }
    }
}
